<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <script type="text/javascript">
        var user= {
            name: "YHSimon",
            age: 1,
            gender: "男"
        };

        //将js对象转换成json字符串
        var str=JSON.stringify(user);
        console.log(str);

        console.log(user);

        //将json字符串转换为js对象
        var user2=JSON.parse(str);
        console.log(user2);

    </script>
</body>
</html>